package com.wind.taobao.api.trade.taobaoke.convert
{
	import com.wind.taobao.api.trade.taobaoke.model.TaobaokeReportMember;
	import com.wind.taobao.core.util.TaobaoConstants;
	
	import mx.collections.ArrayCollection;


	/**
	 * TaobaokeReportMember装换器
	 * @author fxy
	 *
	 */
	public class TaobaokeReportMemberConvert
	{
		/**
		 * 转换TaobaokeReportMember集合
		 */
		public static function convertTaobaokeReportMembers(value:Object, type:String="json"):ArrayCollection
		{
			var taobaokeReportMembers:ArrayCollection=new ArrayCollection();
			if (value != null)
			{
				if (type == TaobaoConstants.JSON)
				{
					if ((value as Array).length > 0)
					{
						for (var i:uint=0; i < (value as Array).length; i++)
						{
							taobaokeReportMembers.addItem(convertTaobaokeReportMember((value as Array)[i]));
						}
					}
				}
				else
				{
					//TODO
				}
			}
			return taobaokeReportMembers;
		}

		/**
		 * 转换TaobaokeReportMember
		 */
		public static function convertTaobaokeReportMember(value:Object, type:String="json"):TaobaokeReportMember
		{
			var taobaokeReportMember:TaobaokeReportMember=new TaobaokeReportMember();
			if (value == null)
				return taobaokeReportMember;
			if (type == TaobaoConstants.XML)
			{
				taobaokeReportMember=convertXMLToTaobaokeReportMember(XML(value), taobaokeReportMember);
			}
			else
			{
				taobaokeReportMember=convertJSONToTaobaokeReportMember(value, taobaokeReportMember);
			}
			return taobaokeReportMember;
		}

		/**
		 * JSON转换为TaobaokeReportMember
		 */
		private static function convertJSONToTaobaokeReportMember(json:Object, taobaokeReportMember:TaobaokeReportMember):TaobaokeReportMember
		{
			if (json.hasOwnProperty(TaobaoConstants.APP_KEY))
			{
				taobaokeReportMember.app_key=json[TaobaoConstants.APP_KEY];
			}
			if (json.hasOwnProperty(TaobaoConstants.OUTER_CODE))
			{
				taobaokeReportMember.outer_code=json[TaobaoConstants.OUTER_CODE];
			}
			if (json.hasOwnProperty(TaobaoConstants.TRADE_ID))
			{
				taobaokeReportMember.trade_id=json[TaobaoConstants.TRADE_ID];
			}
			if (json.hasOwnProperty(TaobaoConstants.PAY_TIME))
			{
				taobaokeReportMember.pay_time=json[TaobaoConstants.PAY_TIME];
			}
			if (json.hasOwnProperty(TaobaoConstants.PAY_PRICE))
			{
				taobaokeReportMember.pay_price=json[TaobaoConstants.PAY_PRICE];
			}
			if (json.hasOwnProperty(TaobaoConstants.AUCTION_ID))
			{
				taobaokeReportMember.auction_id=json[TaobaoConstants.AUCTION_ID];
			}
			if (json.hasOwnProperty(TaobaoConstants.AUCTION_TITLE))
			{
				taobaokeReportMember.auction_title=json[TaobaoConstants.AUCTION_TITLE];
			}
			if (json.hasOwnProperty(TaobaoConstants.AUCTION_NUMBER))
			{
				taobaokeReportMember.auction_number=json[TaobaoConstants.AUCTION_NUMBER];
			}
			if (json.hasOwnProperty(TaobaoConstants.CATEGORY_ID))
			{
				taobaokeReportMember.category_id=json[TaobaoConstants.CATEGORY_ID];
			}
			if (json.hasOwnProperty(TaobaoConstants.CATEGORY_NAME))
			{
				taobaokeReportMember.category_name=json[TaobaoConstants.CATEGORY_NAME];
			}
			if (json.hasOwnProperty(TaobaoConstants.SHOP_TITLE))
			{
				taobaokeReportMember.shop_title=json[TaobaoConstants.SHOP_TITLE];
			}
			if (json.hasOwnProperty(TaobaoConstants.DISCOUNT))
			{
				taobaokeReportMember.discount=json[TaobaoConstants.DISCOUNT];
			}
			if (json.hasOwnProperty(TaobaoConstants.TAOKE_AMOUNT))
			{
				taobaokeReportMember.taoke_amount=json[TaobaoConstants.TAOKE_AMOUNT];
			}
			return taobaokeReportMember;
		}

		/**
		 * XML转换为TaobaokeReportMember
		 */
		private static function convertXMLToTaobaokeReportMember(value:XML, taobaokeReportMember:TaobaokeReportMember):TaobaokeReportMember
		{
			return taobaokeReportMember;
		}


	}
}